<template>
    <div class="main_box" style="padding:10px">
      <div class="add_wrap">
        <el-form label-width="200px" v-if="dataInfo">
          <div class="tit">
            <h2>基础信息</h2>
            <el-button type="success" plain size="small" icon="fa fa-mail-forward" @click="returnList">返回</el-button>
          </div>
          <el-row>
            <el-form-item label="分类Logo:">
              <div class="img-wrapper">
                <el-image title="点击可预览" v-if="dataInfo.classifyLogo" :src="dataInfo.classifyLogo" alt=""
                          :preview-src-list="[dataInfo.classifyLogo]"></el-image>
              </div>
            </el-form-item>
            <el-form-item label="分类名称:">
              <span>{{dataInfo.classifyName}}</span>
            </el-form-item>
            <el-form-item label="二级分类:">
                <span>{{ serverClassifyNames }}</span>
            </el-form-item>
            <el-form-item label="类型:">
                <span>{{ formatClassifyType(dataInfo.classifyType) }}</span>
            </el-form-item>
            <el-form-item label="分类描述:">
              <span>{{dataInfo.classifyContent}}</span>
            </el-form-item>
            <el-form-item label="创建人:">
              <span>{{ dataInfo.createUserName}}</span>
            </el-form-item>
            <el-form-item label="创建时间:">
              <span>{{ dataInfo.createDate }}</span>
            </el-form-item>
            <el-form-item label="修改人:">
              <span>{{ dataInfo.modifyUserName}}</span>
            </el-form-item>
            <el-form-item label="修改时间:">
              <span>{{ dataInfo.modifyDate }}</span>
            </el-form-item>

          </el-row>
        </el-form>
      </div>
    </div>
  </template>

  <script>
    import TopClassifyApi from '@/api/server/topClassify';
    export default {
      data() {
        return {
          dataInfo: {},
        };
      },
      computed: {
        serverClassifyNames(){
            return this.dataInfo.classifyList&&this.dataInfo.classifyList.reduce((a,b)=>a.name+','+b.name)
        }
      },
      mounted() {
        this.getData()
      },
      methods: {
        getData() {
          TopClassifyApi.getTopClassifyInfo({topClassifyId: this.$route.query.id}).then(res => {
            this.dataInfo = res.data
          })
        },
        formatClassifyType(cellValue){
            switch(cellValue){
                case 1:
                    return "大屏生活类"
                case 2:
                    return "大屏医疗类"
            }
        },
        returnList() {
          this.$store.dispatch('delView', this.$route);
          this.$router.push({path: '/server/topClassifyManagement'})
        }
      },

    }

  </script>
  <style lang="scss" scoped>
@import "@/assets/css/views/add.scss";
</style>
